package com.minhang.adsb.constant;

import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@Getter
public enum VersionEnum {
    V1(1, "http直接推送版本"),
    V2(2, "http处理后推送版本"),
    V3(3, "kafka版本");

    private final String description;
    private final Integer value;

    VersionEnum(Integer value,String description) {
        this.description = description;
        this.value = value;
    }

    private static final Map<Integer, VersionEnum> valueMap = Arrays.stream(values())
            .collect(Collectors.toMap(VersionEnum::getValue, Function.identity()));

    public static VersionEnum fromValue(Integer value) {
        return valueMap.getOrDefault(value, V1); // 默认返回V1
    }
}
